import axios from '@/router/axios'

export function getBooks (query = {}) {
  return axios.get('/api/root/books/list', {
    params: query
  })
}

export function delBooks (id) {
  return axios.post('/api/root/books/del', id)
}

export function addBooks (formData) {
  return axios.post('/api/root/books/add', formData)
}

export function updBooks (formData) {
  return axios.post('/api/root/books/upd', formData)
}

export function getToken (cb) {
  return axios.get('/api/root/upload/getToken').then(res => {
    if (res.data.code === 200) {
      cb(null, res.data.msg)
    } else {
      cb(res.data.msg, null)
    }
  }).catch(err => {
    cb(err, null)
  })
}
